<?php


abstract class BaseRingtoneOriginExtra extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $origin_id;


	
	protected $spectrum_path;


	
	protected $spectrum_width;


	
	protected $album_id;


	
	protected $album_name;


	
	protected $track_no;


	
	protected $lyrics;


	
	protected $remark;


	
	protected $checknum;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getOriginId()
	{

		return $this->origin_id;
	}

	
	public function getSpectrumPath()
	{

		return $this->spectrum_path;
	}

	
	public function getSpectrumWidth()
	{

		return $this->spectrum_width;
	}

	
	public function getAlbumId()
	{

		return $this->album_id;
	}

	
	public function getAlbumName()
	{

		return $this->album_name;
	}

	
	public function getTrackNo()
	{

		return $this->track_no;
	}

	
	public function getLyrics()
	{

		return $this->lyrics;
	}

	
	public function getRemark()
	{

		return $this->remark;
	}

	
	public function getChecknum()
	{

		return $this->checknum;
	}

	
	public function setOriginId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->origin_id !== $v) {
			$this->origin_id = $v;
			$this->modifiedColumns[] = RingtoneOriginExtraPeer::ORIGIN_ID;
		}

	} 
	
	public function setSpectrumPath($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->spectrum_path !== $v) {
			$this->spectrum_path = $v;
			$this->modifiedColumns[] = RingtoneOriginExtraPeer::SPECTRUM_PATH;
		}

	} 
	
	public function setSpectrumWidth($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->spectrum_width !== $v) {
			$this->spectrum_width = $v;
			$this->modifiedColumns[] = RingtoneOriginExtraPeer::SPECTRUM_WIDTH;
		}

	} 
	
	public function setAlbumId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->album_id !== $v) {
			$this->album_id = $v;
			$this->modifiedColumns[] = RingtoneOriginExtraPeer::ALBUM_ID;
		}

	} 
	
	public function setAlbumName($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->album_name !== $v) {
			$this->album_name = $v;
			$this->modifiedColumns[] = RingtoneOriginExtraPeer::ALBUM_NAME;
		}

	} 
	
	public function setTrackNo($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->track_no !== $v) {
			$this->track_no = $v;
			$this->modifiedColumns[] = RingtoneOriginExtraPeer::TRACK_NO;
		}

	} 
	
	public function setLyrics($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->lyrics !== $v) {
			$this->lyrics = $v;
			$this->modifiedColumns[] = RingtoneOriginExtraPeer::LYRICS;
		}

	} 
	
	public function setRemark($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->remark !== $v) {
			$this->remark = $v;
			$this->modifiedColumns[] = RingtoneOriginExtraPeer::REMARK;
		}

	} 
	
	public function setChecknum($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->checknum !== $v) {
			$this->checknum = $v;
			$this->modifiedColumns[] = RingtoneOriginExtraPeer::CHECKNUM;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->origin_id = $rs->getInt($startcol + 0);

			$this->spectrum_path = $rs->getString($startcol + 1);

			$this->spectrum_width = $rs->getInt($startcol + 2);

			$this->album_id = $rs->getInt($startcol + 3);

			$this->album_name = $rs->getInt($startcol + 4);

			$this->track_no = $rs->getInt($startcol + 5);

			$this->lyrics = $rs->getString($startcol + 6);

			$this->remark = $rs->getString($startcol + 7);

			$this->checknum = $rs->getInt($startcol + 8);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 9; 
		} catch (Exception $e) {
			throw new PropelException("Error populating RingtoneOriginExtra object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(RingtoneOriginExtraPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			RingtoneOriginExtraPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(RingtoneOriginExtraPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = RingtoneOriginExtraPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setNew(false);
				} else {
					$affectedRows += RingtoneOriginExtraPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = RingtoneOriginExtraPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = RingtoneOriginExtraPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getOriginId();
				break;
			case 1:
				return $this->getSpectrumPath();
				break;
			case 2:
				return $this->getSpectrumWidth();
				break;
			case 3:
				return $this->getAlbumId();
				break;
			case 4:
				return $this->getAlbumName();
				break;
			case 5:
				return $this->getTrackNo();
				break;
			case 6:
				return $this->getLyrics();
				break;
			case 7:
				return $this->getRemark();
				break;
			case 8:
				return $this->getChecknum();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = RingtoneOriginExtraPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getOriginId(),
			$keys[1] => $this->getSpectrumPath(),
			$keys[2] => $this->getSpectrumWidth(),
			$keys[3] => $this->getAlbumId(),
			$keys[4] => $this->getAlbumName(),
			$keys[5] => $this->getTrackNo(),
			$keys[6] => $this->getLyrics(),
			$keys[7] => $this->getRemark(),
			$keys[8] => $this->getChecknum(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = RingtoneOriginExtraPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setOriginId($value);
				break;
			case 1:
				$this->setSpectrumPath($value);
				break;
			case 2:
				$this->setSpectrumWidth($value);
				break;
			case 3:
				$this->setAlbumId($value);
				break;
			case 4:
				$this->setAlbumName($value);
				break;
			case 5:
				$this->setTrackNo($value);
				break;
			case 6:
				$this->setLyrics($value);
				break;
			case 7:
				$this->setRemark($value);
				break;
			case 8:
				$this->setChecknum($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = RingtoneOriginExtraPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setOriginId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setSpectrumPath($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setSpectrumWidth($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setAlbumId($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setAlbumName($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setTrackNo($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setLyrics($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setRemark($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setChecknum($arr[$keys[8]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(RingtoneOriginExtraPeer::DATABASE_NAME);

		if ($this->isColumnModified(RingtoneOriginExtraPeer::ORIGIN_ID)) $criteria->add(RingtoneOriginExtraPeer::ORIGIN_ID, $this->origin_id);
		if ($this->isColumnModified(RingtoneOriginExtraPeer::SPECTRUM_PATH)) $criteria->add(RingtoneOriginExtraPeer::SPECTRUM_PATH, $this->spectrum_path);
		if ($this->isColumnModified(RingtoneOriginExtraPeer::SPECTRUM_WIDTH)) $criteria->add(RingtoneOriginExtraPeer::SPECTRUM_WIDTH, $this->spectrum_width);
		if ($this->isColumnModified(RingtoneOriginExtraPeer::ALBUM_ID)) $criteria->add(RingtoneOriginExtraPeer::ALBUM_ID, $this->album_id);
		if ($this->isColumnModified(RingtoneOriginExtraPeer::ALBUM_NAME)) $criteria->add(RingtoneOriginExtraPeer::ALBUM_NAME, $this->album_name);
		if ($this->isColumnModified(RingtoneOriginExtraPeer::TRACK_NO)) $criteria->add(RingtoneOriginExtraPeer::TRACK_NO, $this->track_no);
		if ($this->isColumnModified(RingtoneOriginExtraPeer::LYRICS)) $criteria->add(RingtoneOriginExtraPeer::LYRICS, $this->lyrics);
		if ($this->isColumnModified(RingtoneOriginExtraPeer::REMARK)) $criteria->add(RingtoneOriginExtraPeer::REMARK, $this->remark);
		if ($this->isColumnModified(RingtoneOriginExtraPeer::CHECKNUM)) $criteria->add(RingtoneOriginExtraPeer::CHECKNUM, $this->checknum);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(RingtoneOriginExtraPeer::DATABASE_NAME);

		$criteria->add(RingtoneOriginExtraPeer::ORIGIN_ID, $this->origin_id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getOriginId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setOriginId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setSpectrumPath($this->spectrum_path);

		$copyObj->setSpectrumWidth($this->spectrum_width);

		$copyObj->setAlbumId($this->album_id);

		$copyObj->setAlbumName($this->album_name);

		$copyObj->setTrackNo($this->track_no);

		$copyObj->setLyrics($this->lyrics);

		$copyObj->setRemark($this->remark);

		$copyObj->setChecknum($this->checknum);


		$copyObj->setNew(true);

		$copyObj->setOriginId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new RingtoneOriginExtraPeer();
		}
		return self::$peer;
	}

} 